<div id="file_container_<?php echo $this->getId()?>" <?php echo $this->getStyleHtml()?>>
<div>
<input type="file" id="file_<?php echo $this->getId()?>"<?php echo $this->getValidateRuleHtml()?>/>
</div>
<p>
<a href="javascript:void(0)" onclick="javascript:$('#file_<?php echo $this->getId()?>').uploadifyUpload()"><?php echo Kd_Localize_Helper::__('share.button.upload')?></a>
</p>
<div>
<ul id="files_<?php echo $this->getId()?>" class="file-selected">
<?php if($this->getValue()):?>
<?php
$_uploadImages = Kd_Util_Array::pack($this->getValue());
foreach($_uploadImages as $image):
?>
<li>
<img class="file-selected-item" src="<?php echo $this->getBaseUrl().$image ?>" width="80px" height="80px"/>
<input type="hidden" name="<?php echo $this->getName()?>" value="<?php echo $this->getBaseUrl().$image ?>"/>
<div class="control">
<a href="javascript:void(0)" onclick="javascript:deleteFileUpload(this, '<?php echo $this->getBaseUrl().$image ?>')">
	<img src="<?php echo Kd_Web::getRouter()->getBaseUrl() ?>pub/share/js/cancel.png"/>
</a>
</div>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</div>
</div>
<script type="text/javascript">
<?php 
$_uploadUrl = $this->getUploadUrl();
$_uploadUrl = Kd_Web::getRouter()->buildUrl('filemanage/file/upload');
?>
$(function() {
  $('#file_<?php echo $this->getId()?>').uploadify({
	  'cancelImg'	: '<?php echo Kd_Web::getRouter()->getBaseUrl() ?>pub/share/js/cancel.png',
	  'uploader'  	: '<?php echo Kd_Web::getRouter()->getBaseUrl()?>pub/share/js/uploadify.swf',
	  'script'    	: '<?php echo $_uploadUrl ?>',
	  'folder'	  	: '/tmp/upload/<?php echo Kd_Util_Random::randomNumeric()?>',
	  'fileExt'		: '<?php echo $this->getFileExtension()?>',
	  'onComplete'	: function(event, id, fileObj, response, data){
		  var json = eval('(' + response + ')');
		  var multiple = <?php echo $this->getMultiple()? 'true': 'false'?>;
		  for(var i = 0; i < json.fileUrls.length; i++){
			  if(!multiple){
				  $('#files_<?php echo $this->getId()?>').empty();
			  }
			  var html = '<li>';
			  html += '<img class="file-selected-item" src="' + json.fileUrls[i] + '" width="80px" height="80px"/>';
			  html += '<input type="hidden" name="<?php echo $this->getName()?>" value="' + json.fileUrls[i] + '"/>';
			  html += '<div class="control">';
			  html += '<a href="javascript:void(0)" onclick="javascript:deleteFileUpload(this, \'' + json.fileUrls[i] + '\')">';
			  html += '<img src="<?php echo Kd_Web::getRouter()->getBaseUrl() ?>pub/share/js/cancel.png"/>'
			  html += '</a></div></li>';
			  $('#files_<?php echo $this->getId()?>').append(html);
		  }
	  }
  });
});
</script>
<?php Kd_Web::getPage()->startScriptBlock('fileuploadscript');?>
function deleteFileUpload(el, fileUrl){
	deleteFile(fileUrl);
	$(el).parent().parent().remove();
}
<?php Kd_Web::getPage()->endScriptBlock();?>